/*
 * Fornecedor.java
 *
 * Created on October 7, 2007, 10:50 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package petstore.model;

import java.util.Collection;
import java.util.Date;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * Entity class Fornecedor
 * 
 * @author Tom Hayden
 */
@Entity
@Table(name = "fornecedor")
@AttributeOverrides( {
    @AttributeOverride(name="id", column=@Column(name="cdfornecedor")),
    @AttributeOverride(name="description", column=@Column(name="nmfantasia")),
    @AttributeOverride(name="active", column=@Column(name="ativo"))
})
public class Fornecedor extends CodeData {

    @Column(name = "nmrazaosocial")
    private String razaoSocial;

    @Column(name = "cnpj")
    private String CNPJ;

    @Column(name = "ie")
    private String IE;

    @Column(name = "nmcontato")
    private String nomeContato;

    @Column(name = "cargocontato")
    private String cargoContato;

    @Column(name = "emailcontato")
    private String emailContato;

    @Column(name = "dtcadastro")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataCadastro;

    @Column(name = "dtvisita")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataVisita;

    @Column(name = "site")
    private String site;

    @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
    @JoinTable(name="fornecedor_telefone",
               joinColumns={@JoinColumn(name="cdfornecedor", referencedColumnName="cdfornecedor")},
               inverseJoinColumns={@JoinColumn(name="cdtelefone", referencedColumnName="cdtelefone")})
    private Collection<Telefone> telefones;
    
    @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
    @JoinTable(name="fornecedor_endereco",
               joinColumns={@JoinColumn(name="cdfornecedor", referencedColumnName="cdfornecedor")},
               inverseJoinColumns={@JoinColumn(name="cdendereco", referencedColumnName="cdendereco")})
    private Collection<Endereco> enderecos;

    /** Creates a new instance of Fornecedor */
    public Fornecedor() {
    }

    public String getRazaoSocial() {
        return razaoSocial;
    }

    public void setRazaoSocial(String razaoSocial) {
        this.razaoSocial = razaoSocial;
    }

    public String getCNPJ() {
        return CNPJ;
    }

    public void setCNPJ(String CNPJ) {
        this.CNPJ = CNPJ;
    }

    public String getIE() {
        return IE;
    }

    public void setIE(String IE) {
        this.IE = IE;
    }

    public String getNomeContato() {
        return nomeContato;
    }

    public void setNomeContato(String nomeContato) {
        this.nomeContato = nomeContato;
    }

    public String getCargoContato() {
        return cargoContato;
    }

    public void setCargoContato(String cargoContato) {
        this.cargoContato = cargoContato;
    }

    public String getEmailContato() {
        return emailContato;
    }

    public void setEmailContato(String emailContato) {
        this.emailContato = emailContato;
    }

    public Date getDataCadastro() {
        return dataCadastro;
    }

    public void setDataCadastro(Date dataCadastro) {
        this.dataCadastro = dataCadastro;
    }

    public Date getDataVisita() {
        return dataVisita;
    }

    public void setDataVisita(Date dataVisita) {
        this.dataVisita = dataVisita;
    }

    public String getSite() {
        return site;
    }

    public void setSite(String site) {
        this.site = site;
    }

    public Collection<Telefone> getTelefones() {
        return telefones;
    }

    public void setTelefones(Collection<Telefone> telefones) {
        this.telefones = telefones;
    }

    public Collection<Endereco> getEnderecos() {
        return enderecos;
    }

    public void setEnderecos(Collection<Endereco> enderecos) {
        this.enderecos = enderecos;
    }
    
}
